package com.tfswx.jkgl.designer.api;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.tfswx.jkgl.designer.dto.stgl.*;
import com.tfswx.jkgl.designer.service.StglService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ricky
 * @date 2021/12/10
 */
@Api(tags = "实体管理")
@RestController
@RequestMapping("api")
@ApiSupport(order = 20)
public class StglController {
    @Resource
    private StglService stglService;

    @ApiOperation("添加实体定义")
    @PostMapping("/addStdy")
    @ApiOperationSupport(order = 10)
    public String addStdy(@RequestBody @Validated StdyAddInputDTO inputDTO) {
        return stglService.addStdy(inputDTO);
    }

    @ApiOperation("删除实体定义")
    @PostMapping("/deleteStdy")
    @ApiOperationSupport(order = 20)
    public Boolean deleteStdy(@RequestBody @Validated StdyDeleteInputDTO inputDTO) {
        return stglService.deleteStdy(inputDTO);
    }

    @ApiOperation("修改实体定义")
    @PostMapping("/updateStdy")
    @ApiOperationSupport(order = 30)
    public Boolean updateStdy(@RequestBody @Validated StdyUpdateInputDTO inputDTO) {
        return stglService.updateStdy(inputDTO);
    }

    @ApiOperation("查询实体定义")
    @PostMapping("/queryStdy")
    @ApiOperationSupport(order = 40)
    public List<StdyQueryOutputDTO> queryStdy(@RequestBody @Validated StdyQueryInputDTO inputDTO) {
        return stglService.queryStdy(inputDTO);
    }

    @ApiOperation("添加字段定义")
    @PostMapping("/addZddy")
    @ApiOperationSupport(order = 50)
    public String addZddy(@RequestBody @Validated ZddyAddInputDTO inputDTO) {
        return stglService.addZddy(inputDTO);
    }

    @ApiOperation("删除字段定义")
    @PostMapping("/deleteZddy")
    @ApiOperationSupport(order = 60)
    public Boolean deleteZddy(@RequestBody @Validated ZddyDeleteInputDTO inputDTO) {
        return stglService.deleteZddy(inputDTO);
    }

    @ApiOperation("修改字段定义")
    @PostMapping("/updateZddy")
    @ApiOperationSupport(order = 70)
    public Boolean updateZddy(@RequestBody @Validated ZddyUpdateInputDTO inputDTO) {
        return stglService.updateZddy(inputDTO);
    }

    @ApiOperation("查询字段定义")
    @PostMapping("/queryZddy")
    @ApiOperationSupport(order = 80)
    public List<ZddyQueryOutputDTO> queryZddy(@RequestBody @Validated ZddyQueryInputDTO inputDTO) {
        return stglService.queryZddy(inputDTO);
    }


    @ApiOperation("查询字段策略")
    @PostMapping("queryZdcl")
    public ZdclQueryOutputDTO queryZdcl() {
        return stglService.queryZdcl();
    }

    @ApiOperation("查询数据库实体列表")
    @PostMapping("queryStlb")
    public List<StlbQueryResult> queryStlb(@RequestBody @Validated StlbQueryInputDTO inputDTO) {
        return stglService.queryStlb(inputDTO);
    }


    @ApiOperation("导入实体、字段、模型")
    @PostMapping("scStdyhzddy")
    public void scStdyhzddy(@RequestBody @Validated StdyhzddyScInputDTO inputDTO) {
        stglService.scStdyhzddy(inputDTO);
    }


}
